package com.oocl.euc.core.builder;

import com.oocl.euc.core.maintenance.model.Users;
import com.oocl.euc.core.maintenance.repository.UsersRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UsersBuilder {

    private Users users;
    @Autowired UsersRepository usersRepository;

    public UsersBuilder defaultBuilder(){
        users = new Users();
        this.users.setStaffId("Test Users Id");
        this.users.setActive(true);
        this.users.setAddress("Test address");
        this.users.setCountry("CHINA-SOUTH");
        this.users.setDepartment("ISD");
        this.users.setDisplayName("MIKE XIE (DOCU-IRIS-ISD-OOCLL/ZHA)");
        this.users.setDomainId("XIEMI2");
        this.users.setEmail("MIKE.XIE@OOCL.COM");
        this.users.setFax(null);
        this.users.setFirstName("MIKE");
        this.users.setGender("M");
        this.users.setJobTitle("ASSISTANT TECHNICAL ENGINEER");
        this.users.setLastName("XIE");
        this.users.setNeedSync(true);
        this.users.setOffice("ZHA");
        this.users.setOfficeCode("ZHA1");
        this.users.setPhone("86-756-3396118");
        this.users.setSection1("IRIS");
        this.users.setSection2("DOCU");
        return this;
    }

    public UsersBuilder withStaffId(String staffId){
        this.users.setStaffId(staffId);
        return this;
    }

    public UsersBuilder withDomainId(String domainId){
        this.users.setDomainId(domainId);
        return this;
    }

    public UsersBuilder withDisplayName(String displayName){
        this.users.setDisplayName(displayName);
        return this;
    }

    public UsersBuilder withDepartment(String department){
        this.users.setDepartment(department);
        return this;
    }

    public UsersBuilder withNeedSync(boolean needSync){
        this.users.setNeedSync(needSync);
        return this;
    }

    public Users create() {
        return this.users;
    }

    public Users saveToDB() {
        usersRepository.save(this.users);
        return this.users;
    }
}
